/* eslint-disable @typescript-eslint/no-var-requires */
const ChildProcess = require('child_process');
const ReadLineSync = require('readline-sync')

/** 输入打包指令 */
function runCmd(cmd) {
    let ls = ChildProcess.spawn(cmd, { shell: true })
    ls.stdout.on('data', (data) => {
        let msg = data.toString();
        console.log(msg);
    });

    ls.stderr.on('data', (data) => {
        console.log(data.toString());
    });

    ls.on('close', (code) => {
        console.log(code);
    });
}

const env = ReadLineSync.question('请选择运行环境(dev|test|pro) 默认dev: ',{encoding:'utf8'}) || 'env';

runCmd(`cross-env VUE_APP_ENV=${env} cross-env VUE_APP_ISAPP=true vue-cli-service serve`);